1 using UnityEngine;
2 using
System.Collections;
3
4 public
class HonkScript : MonoBehaviour {
5
6     AudioSource audioSource;
7     
public AudioClip clip;
8     
bool alreadyHonked = false;
9     
// Use this for initialization
10     
void Start () {
11         audioSource = GetComponent<AudioSource> ();
12     
13     }
14     
15     
// Update is called once per frame
16     
void Update () {
17     
18     }
19
20     
void OnTriggerEnter(Collider other){
21         
if (other.gameObject.tag == "Player" ) {
22             
//if (alreadyHonked == false) {
23             
// alreadyHonked = true;
24                 audioSource.PlayOneShot (clip);
25             
//}
26         }
27     }
28 }


Gõ tìm kiếm nhanh...